package com.travel.config;

import com.travel.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class LoginConfiguration implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册拦截器
        LoginInterceptor loginInterceptor = new LoginInterceptor();

        InterceptorRegistration loginRegistry = registry.addInterceptor(loginInterceptor);
        // 拦截路
        System.out.println("hello");
        //loginRegistry.addPathPatterns("/**").excludePathPatterns("/layui/**");
        loginRegistry.addPathPatterns("/index.html");
        // 排除路径
//        loginRegistry.excludePathPatterns("/css/**").excludePathPatterns("/page/login/**");
//        // 排除资源请求
//        loginRegistry.excludePathPatterns("/login/**");
//       loginRegistry.excludePathPatterns("/js/**");
//        loginRegistry.excludePathPatterns("/images/**");
    }
//    @Override
//
//    public void addViewControllers(ViewControllerRegistry registry) {
//
//        registry.addViewController("/toLogin").setViewName("login");
//        System.out.println("add");
//        //addViewControllers(registry);
//
//    }


}